<!-- 首页 -->
<template>
	<view class="page-index-index">
		<view class="logincenter">
			<image class="logos" src="../../static/images/applogo.png" mode=""></image>
			<view class="center_input">
				<u-input class="inputs" v-model="userName" type="text" placeholder="请输入账号" />
				<u-input class="inputs" v-model="password" type="password" placeholder="请输入密码" />
			</view>
			<view class="okbtns" @click="topaesad">
				登录
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userName: "",
				password: "",
			}
		},
		onLoad(options) {
			if (uni.$func.cache("userInfo")) {
				uni.switchTab({
					url: "./indexlist"
				})
			}
		},
		onShareAppMessage(res) {
			return {
				title: '',
				path: "/pages/index/index"
			}
		},
		onShow() {},
		onReachBottom() {},
		methods: {
			topaesad() {
				uni.$api.common.login({
					password: this.password,
					userName: this.userName
				}).then((res) => {
					uni.$func.cache("token", res.result.access_token)
					uni.$api.common.userscurrent().then((res) => {
						uni.$func.cache("userInfo", res.result)
						uni.switchTab({
							url: "./indexlist"
						})
					});

				});

			},
		}
	}
</script>

<style lang="scss">
	.logincenter {
		text-align: center;
		padding: 200px 80rpx;

		.logos {
			width: 300rpx;
			height: 300rpx;
			margin-bottom: 100rpx;
		}

		.center_input {
			.inputs {
				// display: block;
				width: 100%;
				height: 80rpx;
				border-bottom: 1rpx solid #333333;
				margin-bottom: 80rpx;
			}
		}

		.okbtns {
			width: 100%;
			padding: 20rpx 0;
			border-radius: 50rpx;
			background-color: #E62131;
			color: #ffffff;
			font-size: 36rpx;
		}
	}
</style>